namespace PickGold.Charting.Design
{
    using System;
    using System.Collections;
    using System.Windows.Forms;

    internal class SeriesDataSourceMemberYCheckedListBox : CheckedListBox
    {
        private Chart _chart;
        protected object editValue;
        protected bool usedForYValue;

        public SeriesDataSourceMemberYCheckedListBox(Chart chart, object editValue, bool usedForYValue)
        {
            this.editValue = editValue;
            this.usedForYValue = usedForYValue;
            base.BorderStyle = BorderStyle.None;
            this._chart = chart;
        }

        private void FillList()
        {
            string[] strArray = null;
            if ((this.editValue != null) && (this.editValue is string))
            {
                strArray = ((string) this.editValue).Split(new char[] { ',' });
            }
            foreach (string str2 in this.GetMemberNames())
            {
                bool isChecked = false;
                if (strArray != null)
                {
                    foreach (string str3 in strArray)
                    {
                        if (str2 == str3.Trim())
                        {
                            isChecked = true;
                        }
                    }
                }
                base.Items.Add(str2, isChecked);
            }
        }

        internal virtual ArrayList GetMemberNames()
        {
            object dataSource = null;
            if (ChartWebDesigner.controlDesigner != null)
            {
                dataSource = ChartWebDesigner.controlDesigner.GetDataSource();
            }
            if (dataSource != null)
            {
                return ChartImage.GetDataSourceMemberNames(dataSource, this.usedForYValue);
            }
            return new ArrayList();
        }

        public string GetNewValue()
        {
            string str = string.Empty;
            foreach (object obj2 in base.CheckedItems)
            {
                if (str.Length > 0)
                {
                    str = str + ", ";
                }
                str = str + ((string) obj2);
            }
            return str;
        }

        protected override void OnCreateControl()
        {
            this.FillList();
        }
    }
}

